import React from 'react';
import { connect } from 'umi';
// import { history } from 'umi';
import { get as getPath } from 'object-path';
import { Form, Tabs } from 'antd';
// import { TablePagination } from 'vv-frontend-components';
// import { formatMessage } from 'umi';
// import moment from 'moment';
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
// import DataPick2 from '@/components/DatePicker2';
// import Locale from '@/utils/locale';

import OverList from './OverList';
import OutList from './OutList';
import TripList from './TripList';

class OvertimeList extends React.Component {
    state = {};

    componentDidMount() {}

    changeTab = () => {
        const { dispatch, overtimeList } = this.props;
        dispatch({
            type: 'overtimeList/save',
            payload: {
                pagination: {
                    ...overtimeList.pagination,
                    current: 1,
                    pageSize: 10
                }
            }
        });
    };

    render() {
        const { TabPane } = Tabs;
        let defaultDate;
        if (
            getPath(this.props, 'location.query.date') &&
            getPath(this.props, 'location.query.date') !== 'undefined'
        ) {
            defaultDate = getPath(this.props, 'location.query.date');
        }
        return (
            <PageHeaderWrapper>
                <Tabs defaultActiveKey="list1" style={{ background: '#fff' }}>
                    <TabPane key="list1" tab="加班记录">
                        <OverList date={getPath(defaultDate)} />
                    </TabPane>
                    <TabPane key="list2" tab="外出记录">
                        <OutList date={getPath(defaultDate)} />
                    </TabPane>
                    <TabPane key="list3" tab="出差记录">
                        <TripList date={getPath(defaultDate)} />
                    </TabPane>
                </Tabs>
            </PageHeaderWrapper>
        );
    }
}
export default connect(({ overtimeList, loading }) => ({
    overtimeList,
    loading: loading.models.overtimeList
}))(Form.create()(OvertimeList));
